package com.atguigu.gmall.user.controller;

import com.atguigu.gmall.model.user.UserAddress;
import com.atguigu.gmall.model.user.UserInfo;
import com.atguigu.gmall.user.service.UserAddressService;
import com.atguigu.gmall.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author tongatong
 * @name UserController
 * @description
 * @date 2021/9/24
 * @time 18:43
 */
@Api(tags = "用户管理")
@RestController
@RequestMapping("/api/user")
public class UserController {
    @Resource
    private UserAddressService userAddressService;
    @Resource
    private UserService userService;

    /**
     * 查询用户的地址
     * @param userId 用户id
     * @return 用户地址列表
     */
    @ApiOperation("查询用户的地址")
    @GetMapping("inner/findUserAddressListByUserId/{userId}")
    public List<UserAddress> findUserAddressListByUserId(@PathVariable String userId) {

        return userAddressService.findUserAddressListByUserId(userId);
    }

    @ApiOperation("获取用户信息")
    @GetMapping("inner/getUserInfo/{userId}")
    public UserInfo getUserInfo(@PathVariable("userId") String userId){
        return userService.getUserInfo(userId);
    }

}
